package ch6;

public class BubbleSort {

	public static void main(String[] args) {
		// 冒泡排序
		int[] ar = { 22, 55, 6, 144, 88, 23, 77, 85, 15 };
		int temp;
		for (int i = 0; i < ar.length - 1; i++) {
			for (int j = 0; j < ar.length - 1 - i; j++) {
				if (ar[j] > ar[j + 1]) {
					temp = ar[j];
					ar[j] = ar[j + 1];
					ar[j + 1] = temp;
				}
			}
		}
		System.out.println("排序后：");
		for (int i = 0; i < ar.length; i++) {
			System.out.print(ar[i] + "\t");
		}
	}

}
